<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="http://cdn.amazeui.org/amazeui/2.7.2/css/amazeui.min.css" />
</head>
<body>

	<div class="am-container dataDiv">
			<section class="am-panel am-panel-primary">
			  <header class="am-panel-hd">
			    <h3 class="am-panel-title">考试功能演示</h3>
			  </header>
			  
			  <div class="am-panel-bd">
					<table class="am-table am-table-bordered am-text-center">
						<thead>
							<tr>
								<th colspan="3">
									<button title="刷新" id="reload" class="am-btn am-btn-primary">刷新数据</button>
								</th>
							</tr>
							
						</thead>
						<tbody>
						<form id="submitForm">
						<c:forEach items="${list }" var="admin" varStatus="sta">
							<tr>
								<td ><input value=${admin.id } name="adminId"  type="checkbox"></td>
								<td>${admin.name }</td>
								<td>${admin.age }</td>
							</tr>
						</c:forEach>
						</form>
							<tr>
								
								<td colspan="3">
									<button onclick="selectedAllClick()" class="am-btn am-btn-primary" title="点击后将所有数据的checkbox修改为选中状态">全选</button>
									<button onclick="notSelectedClick()" class="am-btn am-btn-primary" title="点击后将所有数据的checkbox修改为未选中状态">全不选</button>
									<button class="am-btn am-btn-primary" onclick="InverseClick()" title="点击后，已选择的checkbox改为未选择，未选择的checkbox改为已选择">反选</button>
									<button class="am-btn am-btn-warning" onclick="SubmitSelectedClick()" title="点击后提交已选择数据的value值">提交已选择数据</button>
								</td>
							</tr>
							
						</tbody>
					</table>
					<div>
						<p id="message"></p>
					</div>
			  </div>
			</section>
		</div>
<script type="text/javascript" src='<c:url value="../static/js/jquery-1.12.4.min.js"></c:url>'></script>
<script type="text/javascript">
$(function(){
	$("#reload").on("click",function(){
		$(".am-panel-bd").load("admin/reload.do");
	})
})


function selectedAllClick(){
	$("input").each(function(){
		if(!($(this).is(":checked"))){
			$(this).attr("checked","checked");
		}
		
	})
}
function notSelectedClick(){
	$("input").each(function(){
		if($(this).is(":checked")){
			$(this).removeAttr("checked");
			
		}
	})
}
function InverseClick(){
	$("input").each(function(){
		if($(this).is(":checked")){
			$(this).removeAttr("checked");
		}else{
			$(this).attr("checked","checked");
		}
	})
}
function SubmitSelectedClick(){
	$("input").each(function(){
		if($(this).is(":checked")){
			$.post("admin/selected.do",$("#submitForm").serialize(),function(data){
				$("#message").html(data.message);
			});
		}
	})
}




</script>	
		
</body>
</html>


